﻿# -*- encoding: utf-8 -*- 



from datetime import datetime, timedelta
from openerp import SUPERUSER_ID
from openerp import api, fields, models, _
import openerp.addons.decimal_precision as dp
from openerp.exceptions import UserError
from openerp.tools import float_is_zero, float_compare, DEFAULT_SERVER_DATETIME_FORMAT

class FHsaasMK_FHsaasTB(models.Model):
    _name = 'FHsaasMK.FHsaasTB'
    _description = u'FHsaasZW'
    #_rec_name='FClass'
    def get_employee(self):
        obj = self.env['hr.employee']
        idsobj = obj.search([('user_id','=',self.env.user.id)])
        print('-------------------------------------')		
        print(self.env.user.id)		
        #print(ids)	
        res = idsobj.read()
        print(res)					
        return res and res[0]['id'] or 0
			
			
FHSAAS_columns  

    order_line = fields.One2many('FHsaasMK.FHsaasTBline', 'pay_id', string='Order Lines', copy=True)

	
		
    @api.model		
    def create(self, vals):
        result = super(FHsaasMK_FHsaasTB, self).create(vals)	
        return result
    @api.multi		
    def write(self, values):
	    
        result = super(FHsaasMK_FHsaasTB, self).write(values)		
		
        return result
    @api.multi
    def unlink(self):
	
        return super(FHsaasMK_FHsaasTB, self).unlink()
    @api.multi
    def copy(self, default=None):
        return super(FHsaasMK_FHsaasTB, self).copy(default)
    @api.multi
    def search(self, args, offset=0, limit=None, order=None, context=None, count=False):
        domain =None		
        domain = [('state', '=', '0')]		
        return super(FHsaasMK_FHsaasTB, self).search(args, offset=offset, limit=limit, order=order, count=count)		
FHsaasMK_FHsaasTB() #对象定义结束
class FHsaasMK_FHsaasTBline(models.Model):
    _name = 'FHsaasMK.FHsaasTBline'
    _description = u'测试子表'
    #_rec_name='FClass'
    def get_employee(self, cr, uid, context={}):
        obj = self.pool.get('hr.employee')
        ids = obj.search(cr, uid, [('user_id','=',uid)])
        res = obj.read(cr, uid, ids, ['id','name'], context)
        return res and res[0]['id'] or 0

    pay_id=fields.Many2one('FHsaasMK.FHsaasTB',u'FHsaasMK_FHsaasTB',required=True, ondelete='cascade', index=True, copy=False)
    fkec=fields.Char(u'课程',readonly=False,required=False,translate=False)
    fkecsl=fields.Integer(u'课时',readonly=False,required=False,translate=False)
    FAddperson =fields.Many2one('hr.employee',u'添加人',readonly=False,required=False,translate=False)
    FConsultant=fields.Many2one('hr.employee',u'班主任',readonly=False,required=False,translate=False)					   
    FAdddate= fields.Datetime(u'添加日期',readonly=False,required=False,translate=False)
    state=fields.Selection([('0',u'未分班'),('1',u'已分班')],u'是否分班',readonly=False,required=False,translate=False)					   
    FDisable=fields.Selection([('0',u'启用'),('1',u'停用')],u'是否停用',readonly=False,required=False,translate=False) 


	
FHsaasMK_FHsaasTBline() #对象定义结束
